#ifndef __ShaderObj_H__
#define __ShaderObj_H__

class ShaderObj
{

  public:
    ShaderObj();
    ~ShaderObj();
    
    char str[4096]; // For error messages from the GLSL compiler and linker.
    
    PFNGLCREATEPROGRAMPROC         glCreateProgram;
    PFNGLDELETEPROGRAMPROC         glDeleteProgram;
    PFNGLUSEPROGRAMPROC            glUseProgram;
    PFNGLCREATESHADERPROC          glCreateShader;
    PFNGLDELETESHADERPROC          glDeleteShader;
    PFNGLSHADERSOURCEPROC          glShaderSource;
    PFNGLCOMPILESHADERPROC         glCompileShader;
    PFNGLGETPROGRAMIVPROC          glGetProgramiv;
    PFNGLGETSHADERIVPROC           glGetShaderiv;
    PFNGLATTACHSHADERPROC          glAttachShader;
    PFNGLGETSHADERINFOLOGPROC      glGetShaderInfoLog;
    PFNGLGETPROGRAMINFOLOGPROC     glGetProgramInfoLog;
    PFNGLLINKPROGRAMPROC           glLinkProgram;
    PFNGLGETUNIFORMLOCATIONPROC    glGetUniformLocation;
    PFNGLUNIFORM4FPROC             glUniform4f;
    PFNGLUNIFORM1FPROC             glUniform1f;
    PFNGLUNIFORM1IPROC             glUniform1i;
    PFNGLMULTITEXCOORD2FARBPROC    glMultiTexCoord2fARB;
    PFNGLACTIVETEXTUREARBPROC      glActiveTextureARB;
    PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
    
    int loadExtensions();
    
  	bool	loadVertShader( std::string fileName );
  	bool	loadFragShader( std::string fileName );
  	bool	link();
  	
  	GLint	getUniformLocation( const char * varName );
  	
  	void	bind();
  	void	unbind();
  	
  	void	setFloat1Uniform( const char * varName, GLfloat value );
  	void	setFloat2Uniform( const char * varName, GLfloat val1, GLfloat val2 );
  	void	setFloat3Uniform( const char * varName, GLfloat val1, GLfloat val2, GLfloat val3 );
  	void	setInt1Uniform( const char * varName, GLint value );
  	
  	void	setSamplerUniform( const char * varName, GLuint texture );
  	void	setSamplerCubeUniform( const char * varName, GLuint texture );
  	
  	void	setActiveTexture(  GLenum unit );
  	
  private:
    
  	GLint				m_nID;
  	GLint				m_vertCompiled;
  	GLint				m_fragCompiled;
  	GLint				m_linked;
  	GLint				m_nNumTextures;
  	
  	GLhandleARB			m_programObject;
  	GLhandleARB			m_vertexShaderObject;
  	GLhandleARB			m_fragmentShaderObject;
  	
};

#endif
